{
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  },
  "name": "9879Lec11"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "# MTH 9879 Market Microstructure Models,    Spring 2015 \n\n## Lecture 11: Latency and order routing\n\nTai-Ho Wang    \nDepartment of Mathematics   \n  \n  \n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2014/09/BCCUNYstacked_BLK.jpg\" align = \"center\" width=160></h2>  \n\n$$\n\\newcommand{\\bea}{\\begin{eqnarray}}\n\\newcommand{\\eea}{\\end{eqnarray}}\n\\newcommand{\\supp}{\\mathrm{supp}}\n\\newcommand{\\F}{\\mathcal{F} }\n\\newcommand{\\cF}{\\mathcal{F} }\n\\newcommand{\\E}{\\mathbb{E} }\n\\newcommand{\\Eof}[1]{\\mathbb{E}\\left[ #1 \\right]}\n\\def\\Cov{{ \\mbox{Cov} }}\n\\def\\Var{{ \\mbox{Var} }}\n\\newcommand{\\1}{\\mathbf{1} }\n\\newcommand{\\p}{\\partial}\n\\newcommand{\\PP}{\\mathbb{P} }\n\\newcommand{\\Pof}[1]{\\mathbb{P}\\left[ #1 \\right]}\n\\newcommand{\\QQ}{\\mathbb{Q} }\n\\newcommand{\\R}{\\mathbb{R} }\n\\newcommand{\\DD}{\\mathbb{D} }\n\\newcommand{\\HH}{\\mathbb{H} }\n\\newcommand{\\spn}{\\mathrm{span} }\n\\newcommand{\\cov}{\\mathrm{cov} }\n\\newcommand{\\HS}{\\mathcal{L}_{\\mathrm{HS}} }\n\\newcommand{\\Hess}{\\mathrm{Hess} }\n\\newcommand{\\trace}{\\mathrm{trace} }\n\\newcommand{\\LL}{\\mathcal{L} }\n\\newcommand{\\s}{\\mathcal{S} }\n\\newcommand{\\ee}{\\mathcal{E} }\n\\newcommand{\\ff}{\\mathcal{F} }\n\\newcommand{\\hh}{\\mathcal{H} }\n\\newcommand{\\bb}{\\mathcal{B} }\n\\newcommand{\\dd}{\\mathcal{D} }\n\\newcommand{\\g}{\\mathcal{G} }\n\\newcommand{\\half}{\\frac{1}{2} }\n\\newcommand{\\T}{\\mathcal{T} }\n\\newcommand{\\bit}{\\begin{itemize}}\n\\newcommand{\\eit}{\\end{itemize}}\n\\newcommand{\\beq}{\\begin{equation}}\n\\newcommand{\\eeq}{\\end{equation}}\n\\newcommand{\\tr}{\\mbox{tr}}\n\\newcommand{\\underbar}{\\underline}\n$$"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "## Outline of Lecture 11\n\n-   A model of latency cost due to Moallemi and Sa\u011flam\n\n-   Smart order routing algorithms\n\n    -   Almgren and Harts\n\n    -   Laruelle, Lehalle, and Pag\u00e8s\n\n    -   Kearns et al.\n\n-   Dependence of routing decisions on fee structure (Maglaras et al.)\n\n-   Optimal limit/market order placement (Cont and Kukanov)\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Overview of execution algorithm design\n\nTypically, an execution algorithm has three layers:\n\n-   The macrotrader\n\n    -   This highest level layer decides how to slice the order: when\n        the algorithm should trade, in what size and for roughly how\n        long.\n\n-   The microtrader\n\n    -   Given a slice of the order to trade (a child order), this level\n        decides whether to place market or limit orders and at what\n        price level(s).\n\n-   The smart order router\n\n    -   Given a limit or market order, which venue should this order be\n        sent to?\n\nIn this lecture, we are concerned with the lowest level of the\nalgorithm: Where to send orders and the effect of latency.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Latency\n\nWe can identify a number of reasons why low latency should be important\nto traders:\n\n-   The greater the latency, the more stale information is.\n\n    -   What use is an old order book signal?\n\n-   In a market with price and time priority, being ahead in the limit\n    order queue gives a greater chance of execution.\n\n-   The ability to cancel orders ahead of others can be very valuable.\n\nRelative latency rather than absolute latency is what really counts.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Moallemi Sa\u011flam\n\n-   The idea of the Moallemi-Sa\u011flam (MS) model is to compare the\n    expected profits on a limit order strategy with and without latency.\n\n-   They end up with a simple formula that estimates the cost of latency\n    $CL$ as a fraction of the cost of immediacy $\\delta$ (basically the\n    bid-ask spread) as follows:\n    \n    $$CL \\approx \\frac{\\sigma \\sqrt{\\Delta t}}{\\delta}\\,\\sqrt{\\log{\\frac{\\delta^2}{2\\,\\pi\\,\\sigma^2\\,\\Delta t}}}$$\n    \n\n-   We see that the formula depends only on the ratio\n\n    $$\\frac{\\sigma \\sqrt{\\Delta t}}{\\delta},$$\n    \n    the characteristic\n    fraction of the spread that the stock price can move between the\n    time the order is sent and the time the order is\n    received by the exchange.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Comparative statics\n\nThe cost of latency $CL$:\n\n-   Increases as latency increases.\n\n-   Increases as volatility increases.\n\n-   Decreases as the bid-offer spread increases.\n\nFor a small-tick stock, it is found empirically that\n\n$$\\delta \\approx 2\\,\\sigma \\sqrt{\\tau}$$\n\nwhere $\\tau$ is the\ncharacteristic time between trades. Then, if\n$\\epsilon:=\\Delta t/(4\\,\\tau)$, we have, as $\\epsilon \\to 0$,\n\n$$CL \\approx \\sqrt{\\epsilon\\,\\log{\\frac{1}{2\\,\\pi\\,\\epsilon}}}$$\n\n\n-   Thus, the more active the stock, the more important it is to have\n    low latency.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The MS trading strategy\n\nIn the MS model\n\n-   The objective is to sell one share of stock.\n\n-   The bid price evolves as arithmetic Brownian motion (ABM).\n\n-   Impatient traders arrive at the rate $\\mu$. These traders execute at\n    the bid price plus $\\delta$.\n\n-   When there is no latency, the optimal strategy is to peg a limit\n    order $\\ell_t$ at the bid price $S_t$ plus $\\delta$.\n\n    -   Orders are continuously canceled and replaced.\n\n-   If the limit order is not filled by time $T$, a market sell order is\n    sent.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Limit order execution in the MS model\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/MoallemiFigure1.png\" align = \"center\" width=600></h2>"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The optimal strategy with no latency\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/MoallemiFigure2.png\" align = \"center\" width=600></h2>\nWhen there is no latency, the expected cost saving relative to a market\norder is given by \n\n$$h_0=\\left(1-e^{-\\mu\\,T}\\right)\\,\\delta$$"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Introducing latency\n\n-   The interval $[0,T]$ is split into $n$ subintervals of length\n    $\\Delta t=T/n$.\n\n    -   $\\Delta t$ is the system latency.\n\n-   The trader sets the price $\\ell_i$ of the limit order at time\n    $t_i=i\\,\\Delta t$.\n\n-   This order does not reach the market until time\n    $t_{i+1}=t_i+\\Delta t$. It is active from time $t_{i+1}$ to time\n    $t_{i+2}$.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Scenarios\n\nBetween time $t_i$ when the limit price $\\ell_i$ is set and time\n$t_{i+1}$ when the limit order with this price reaches the market, three\nscenarios can unfold:\n\n1.  An impatient buyer can arrive with probability $\\mu\\,\\Delta t$. The\n    limit order $\\ell_{i-1}$ in force at that time will be executed if\n    $\\ell_{i-1} \\leq S_i+\\delta$. The one share is sold and there is no\n    more trading.\n\n2.  If $S_{i+1} \\geq \\ell_i$, the limit order will be marketable when it\n    reaches the market and will be filled. Again, the one share is sold\n    and there is no more trading.\n\n3.  Otherwise, the limit order at $\\ell_i$ stays in the book for the\n    next period $[t_{i+1},t_{i+2})$. The process continues.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The optimization problem\n\nThe trader is assumed to be risk-neutral. He seeks to solve the\noptimization problem\n\n$$h_0(\\Delta t)=\\max_{\\{\\ell_0,...,\\ell_{n-1}\\}}\\,\\mathbb{E} [P]-S_0$$\n\nwhere $P$ is the sale price of the stock.\n\nThis problem may be solved exactly using dynamic programming with the\nboundary condition that if there is only one period left, the\ncontinuation value is zero because at that point, a market order must be\nsubmitted.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Intuition behind the solution\n\n-   Consider the situation r at time $t=0$ when the bid price is $S_0$.\n\n-   If there were no latency, the optimal strategy would be to peg our\n    sell order to the offer at $S_0+\\delta$; if an impatient buyer\n    arrives, our probability of selling to him is one.\n\n-   If there is latency, this strategy is no longer optimal because the\n    probability of a fill after time $\\Delta t$ is only $1/2$.\n\n-   By lowering the limit price a little however, we can significantly\n    increase the probability of trading with an impatient buyer thus\n    potentially significantly increasing our potential cost saving\n    relative to a market order.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The effect of latency on the optimal choice of limit price\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/MoallemiFigure4.png\" align = \"center\" width=600></h2>"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The probability of a fill\n\n-   If the limit price $\\ell_0=S_0+\\delta$, the probability of execution\n    (conditional on the arrival of an impatient trader) is\n    \n    $$\\Pr(\\ell_0 \\leq S_1+\\delta)=\\Pr(S_0+\\delta \\leq S_0+\\sigma\\,\\sqrt{\\Delta t} \\,Z +\\delta)=\\Pr(Z\\geq 0)=\\frac{1}{2}$$\n    \n    where $Z\\sim N(0,1)$.\n\n\n-   If the limit price $\\ell_0=S_0+\\delta-C\\,\\sigma\\,\\sqrt{\\Delta t}$,\n    the probability of execution (conditional on the arrival of an\n    impatient trader) is\n\n    \\begin{eqnarray*}\n    \\Pr(\\ell_0 \\leq S_1+\\delta)&=&\\Pr(S_0+\\delta - C\\,\\sigma\\,\\sqrt{\\Delta t} \\leq S_0+\\sigma\\,\\Delta t \\,Z +\\delta)\\\\\n    &=&\\Pr(Z\\geq -C)>\\frac{1}{2}\\end{eqnarray*}\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Heuristic solution for small $\\Delta t$\n\n-   We can get very close to the optimal solution by greedily maximizing\n    the probability of interacting with an impatient buyer at each step.\n\n-   With $\\ell_0=S_0+u$, The optimal value $u^*$ of $u$ is then given by\n\n    \\begin{eqnarray*}\n    u^*= \\arg\\max_u \\mathbb{E} \\left[(S_0+u-S_1)\\,\\mathbf{1} _{\\mathcal{E} }\\right]\\end{eqnarray*}\n\n    where $\\mathcal{E} $ is the event that\n    $S_1 \\leq S_0+u\\leq S_1+\\delta$\n\n    -   If $S_1 > S_0+u$, the limit order becomes marketable at time\n        $t_1$ and is executed at the bid.\n\n    -   If $S_0+u > S_1+\\delta$, the limit order cannot be filled by an\n        impatient buyer.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Formulation of solution\n\nBy assumption $S_1-S_0 = \\sigma\\,\\sqrt{\\Delta t}\\,z$ with\n$z \\sim N(0,1)$. Let\n\n$$x=\\frac{u}{\\sigma\\,\\sqrt{\\Delta t}};\\quad \\Delta = \\frac{\\delta}{\\sigma\\,\\sqrt{\\Delta t}}.$$\n\nThen\n\n$$\\mathbb{E} \\left[(S_0+u-S_1)\\,\\mathbf{1} _{\\mathcal{E} }\\right]=\\sigma\\,\\sqrt{\\Delta t}\\,\\int_{x-\\Delta}^x \\,(x - z) N'(z)\\,dz.$$\n\nDefine the dimensionless ratio $\\theta^* = u^*/\\delta$. Then\n\n$$\\theta^* =  \\arg\\max_x \\frac{1}{\\Delta}\\,\\int_{x-\\Delta}^x \\,(x - z) N'(z)\\,dz.$$\n\n\n-   Note that $\\theta^*$ depends only on $\\Delta$ which in turn depends\n    only on latency expressed in the natural timescale\n    $(\\delta/\\sigma)^2$.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Numerical solution\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/MoallemiSaglam.png\" align = \"center\" width=600></h2>\nFigure 1: Graph of optimal limit order level $\\theta^*(\\Delta)$ vs\n$\\Delta = \\delta/{\\sigma\\,\\sqrt{\\Delta t}}$"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Cost of latency\n\nThe proportion of profitability lost due to latency is given by $\nCL := 1-\\theta^*(\\Delta) \n$. We can redo the plot in terms of latency $\\tau$ in normalized units\n(which is just $1/\\Delta^2$).\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/CL.png\" align = \"center\" width=600></h2>\nFigure 2: Cost of latency vs normalized latency $\\tau$"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Solution\n\nDefine\n\n\\begin{eqnarray*}\nf(x) &=& \\int_{x-\\Delta}^x \\,(x - z) N'(z)\\,dz\\\\ &=& x\\,\\left[N(x)-N(x-\\Delta)\\right] + N'(x)-N'(x-\\Delta).\\end{eqnarray*}\n\nThe maximum is found when $f'(x)=0$.\n\n\\begin{eqnarray*}\nf'(x) &=& N(x)-N(x-\\Delta) +x\\,\\left[N'(x)-N'(x-\\Delta)\\right] + N''(x)-N''(x-\\Delta)\\\\\n&=&N(x)-N(x-\\Delta) +x\\,\\left[N'(x)-N'(x-\\Delta)\\right]-x\\, N'(x)+(x-\\Delta)\\,N'(x-\\Delta)\\\\\n&=&N(x)-N(x-\\Delta) -\\Delta\\,N'(x-\\Delta).\\end{eqnarray*}\n\nFormally\n$$\\theta^* =  \\left\\{x :  N(x)-N(x-\\Delta) -\\Delta\\,N'(x-\\Delta)=0  \\right\\}.$$"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "We are interested in the limit $\\Delta \\to \\infty$,\n$\\Delta-x =:\\epsilon \\to 0$. Then\n\n$$f'[x] \\sim 1- N(-\\epsilon)- \\Delta\\,N'(-\\epsilon) = 0.$$\n\nFor this\nequation to have a solution, we must have\n\n$$\\Delta\\,N'(-\\epsilon) \\sim \\Delta\\,e^{-\\epsilon^2/2} \\sim 1$$\n\nfrom\nwhich it follows that $\\epsilon \\sim \\sqrt{\\log \\Delta}$. Then\n$N(-\\epsilon) \\to 0$ as $\\epsilon \\to 0$\nand\n\n$$\\Delta\\,N'(-\\epsilon)=\\Delta \\,\\frac{e^{-\\epsilon^2/2}}{\\sqrt{2\\,\\pi}} \\approx 1$$\n\nwhich has the solution\n\n$$\\epsilon \\approx \\sqrt{2\\,\\log \\frac{\\Delta}{\\sqrt{2\\,\\pi}}}= \\sqrt{\\log \\frac{\\Delta^2}{{2\\,\\pi}}}.$$\n\nDefine the normalized latency\n$\\tau =\\sigma^2\\, \\Delta t/ \\delta^2 = 1/\\Delta^2$. By definition of the\ncost of latency,\n\n$$CL = \\frac{\\epsilon}{\\Delta} \\approx \\sqrt{ \\tau}\\, \\sqrt{-\\log 2\\,\\pi\\,\\tau}= \\sqrt{-\\tau\\,\\log 2\\,\\pi\\,\\tau}$$\n\nwhich coincides with the result of [Moallemi and Sa\u011flam]<sup id=\"cite_ref-Moallemi\" class=\"reference\"><a href=\"#cite_note-Moallemi\"><span>[</span>6<span>]</span></a></sup>."
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Approximation quality\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/CLapprox.png\" align = \"center\" width=600></h2>\nFigure 3: Cost of latency vs normalized latency $\\tau$. Exact (numerical)\nsolution in red, approximate formula in blue."
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Numerical estimates of cost of latency\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/LatencyCost.png\" align = \"center\" width=600></h2>"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Order routing\n\n-   There are currently approximately 13 lit venues and over 40 dark\n    venues in the US.\n\n    -   On the one hand, it would be prohibitively complicated and\n        expensive to route to all of them.\n\n    -   On the other hand, by not routing to a particular venue, the\n        trader misses out on potential liquidity, and all things being\n        equal, will cause incur greater market impact.\n\n\n-   Most traders have to use a smart order routing (SOR) algorithm\n    <font color=blue> provided by a dealer</font>.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Turnover by lit venue (from Fidessa)\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/LitVenues.png\" align = \"center\" width=600></h2>"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### List of dark pools (from Wikipedia)\n\n<span>**Independent dark pools**</span>\n\n-   Instinet\n\n-   Liquidnet\n\n-   NYFIX Millennium\n\n-   Posit/MatchNow from Investment Technology Group (ITG)\n\n-   Pulse Trading BlockCross\n\n-   RiverCross\n\n-   SmartPool\n\n-   TORA Crosspoint\n\n-   ETF One\n\n<span>**Broker-dealer-owned dark pools**</span>\n\n-   Barclays Capital - LX Liquidity Cross\n\n-   BNP Paribas\n\n-   BNY ConvergEx Group (an affiliate of Bank of New York Mellon)\n\n-   Cantor Fitzgerald - Aqua Securities\n\n-   Citi - Citi Match, Citi Cross\n\n-   Credit Agricole Cheuvreux - BLINK\n\n-   Credit Suisse - CrossFinder\n\n-   Fidelity Capital Markets\n\n-   GETCO - GETMatched\n\n-   Goldman Sachs SIGMA X\n\n-   Knight Capital Group - Knight Link, Knight Match\n\n-   Deutsche Bank Global Markets - DBA (Europe), SuperX ATS (U.S.)\n\n-   Merrill Lynch - Instinct-X\n\n-   Morgan Stanley - NightVision\n\n-   Nomura - Nomura NX\n\n-   Soci\u00e9te G\u00e9n\u00e9rale - ALPHA Y\n\n-   UBS Investment Bank - UBS ATS, UBS MTF, UBS PIN\n\n-   Daiwa - DRECT\n\n-   Wells Fargo Securities - WELX\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### List of dark pools (from Wikipedia)\n\n<span>**Consortium-owned dark pools**</span>\n\n-   BIDS Trading - BIDS ATS\n\n-   LeveL ATS\n\n<span>**Exchange-owned dark pools**</span>\n\n-   International Securities Exchange\n\n-   NYSE Euronext\n\n-   BATS Trading\n\n-   Direct Edge\n\n-   Swiss Block\n\n-   Nordic@Mid\n\n<span>**Other dark pools**</span>\n\n-   Chi-X\n\n-   Turquoise\n\n<span>**Dark Pool Aggregators**</span>\n\n-   Bloomberg Tradebook\n\n-   Fidessa - Spotlight\n\n-   SuperX+ Deutsche Bank\n\n-   ASOR Quod Financial\n\n-   Progress Apama\n\n-   ONEPIPE - Weeden & Co. & Pragma Financial\n\n-   Xasax Corporation\n\n-   Crossfire - Credit Agricole Cheuvreux\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Smart order routing (SOR)\n\n-   The goal of an SOR algorithm is to buy (or sell) as many shares as\n    possible in the shortest time by optimally allocating orders across\n    both lit and dark venues.\n\n    -   In the case of lit venues, there are hidden orders so there is\n        typically more liquidity available than is displayed.\n\n        -   Where to route an order involves not just visible liquidity\n            but also expected costs of execution.\n\n    -   In dark venues, by definition, all liquidity is hidden.\n\n\n-   We will describe\n\n    -   A heuristic algorithm due to Almgren and Harts\n\n    -   An algorithm due to Charles-Albert Lehalle and his collaborators\n\n    -   An algorithm based on machine learning techniques due to Michael\n        Kearns and his collaborators.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The Almgren and Harts (AH) algorithm\n\n-   The idea of this algorithm is that the more hidden quantity is\n    detected in a given venue, the more hidden quantity there is likely\n    to be.\n\n    -   Recall that this is a characteristic of distributions with\n        fatter tails than exponential.\n\n    -   Also, we believe in power-law distribution of quantity in which\n        case this assumption would definitely be justified.\n\n-   For simplicity, let\u2019s focus on the sale of stock.\n\n-   If hidden quantity $w$ is detected (by selling more than the visible\n    quantity) on a particular venue, the current estimate of hidden\n    liquidity is increased by $w$.\n\n-   If no hidden quantity quantity is detected on a venue, the existing\n    estimate is decremented by a factor $\\rho$.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Conditional distribution of quantity: Exponential case\n\nSuppose that the distribution of order sizes $Q$ is exponential so that\n\n$$\\Pr(Q>n)= \\frac{1}{\\lambda}\\,e^{-\\lambda\\,n}$$\n\nAssuming the\nconditional probability that hidden quantity is greater than $n$ given\nthat $n$ slices have already been observed is given by\n\n\\begin{eqnarray*}\n\\Pr(Q\\geq (n+1)|Q\\ge n)=\\frac{\\Pr(Q\\geq (n+1))}{\\Pr(Q\\ge n)}=e^{-\\lambda}\\end{eqnarray*}\n\nIf the distribution of $Q$ is exponential, the conditional probability\nof more quantity is independent of the quantity already observed.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Conditional distribution of quantity: Power-law case\n\nSuppose that the distribution of order sizes $Q$ is power-law so that\n\n$$\\Pr(Q>n)= \\frac{C}{n^\\alpha}$$\n\nAssuming the conditional probability\nthat hidden quantity is greater than $n$ given that $n$ slices have\nalready been observed is given by\n\n\\begin{eqnarray*}\n\\Pr(Q\\geq (n+1)|Q\\ge n)&=&\\frac{\\Pr(Q\\geq (n+1))}{\\Pr(Q\\ge n)}\\\\\n&=&\\left(\\frac{n}{n+1}\\right)^\\alpha\\\\\n&\\to& 1 \\text{ as } n \\to \\infty\\end{eqnarray*}\n\nIf the distribution of $Q$ is power-law, the conditional probability of\nmore quantity tends to $1$ as the quantity observed increases.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The AH algorithm\n\nOur goal is to execute a sell order as quickly as possible by optimally\nallocating quantity to all $N$ venues. To avoid eating into the book, we\nsend IOC (\u201cimmediate or cancel\u201d) orders only. We will simplify the\nAlmgren-Harts algorithm by assuming no liquidity above the displayed\nbest bid.\n\n-   We allocate quantity quasi-greedily sequentially to the venue with\n    the highest estimated quantity, visible and hidden.\n\n-   If we see a fill of size $n_{j}$ when the displayed quantity is\n    $q_{j}$ on the $j$th venue, the pre-existing liquidity estimate\n    $R_j$ is decayed by a factor $\\rho$ and incremented by the detected\n    hidden liquidity: \n    \n    $$R_j \\mapsto \\rho\\,R_j+(n_j-q_j)^+$$\n\n\n-   Repeat until our quantity is exhausted and the order is completed.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### A stochastic Lagrangian algorithm\n\n[Laruelle, Lehalle and Pag\u00e8s]<sup id=\"cite_ref-LLP\" class=\"reference\"><a href=\"#cite_note-LLP\"><span>[</span>4<span>]</span></a></sup> propose the following way of looking at optimal allocation to dark\npools.\n\n-   Let be $V$ be the total volume to be executed\n\n-   For the $i$th dark pool, $\\rho_i$ is the relative cost saving, $D_i$\n    is the quantity available, and $r_i$ is the proportion of the order\n    sent there.\n\n-   Then the cost of a buy order is given by\n\n    $$\\mathcal{C} =S\\,\\left\\{V-\\sum_{i=1}^N\\,\\rho_i\\,\\min(r_i\\,V,D_i)\\right\\}$$\n    \n    where the $\\rho_i \\in (0,1)$.\n\n-   The optimization problem is then\n\n    $$\\max_{r_i} \\left\\{\\sum_{i=1}^N\\,\\rho_i\\,\\mathbb{E} \\left[\\min(r_i\\,V,D_i)\\right]: \\sum_{i=1}^N r_i=1, r_i \\geq 0\\; \\forall i \\right\\}.$$\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The mean execution function\n\nGiven a dark pool, define its <span>*mean execution function*</span>\n\n$$\\varphi(r)=\\rho\\,\\mathbb{E} \\left[\\min(r\\,V,D)\\right].$$\n\nThen\n$\\varphi$ is finite, nonzero, and concave in $r$. Also\n\n$$\\varphi'(r)=\\rho\\,\\mathbb{E} \\left[{\\bf 1}_{\\{r\\,V < D\\}}\\,V\\right].$$\n\nThe\noptimization problem becomes\n\n$$\\max_{r_i} \\left\\{\\sum_{i=1}^N\\,\\varphi_i(r_i),\\sum_{i=1}^N r_i=1\\right\\}$$\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Solution\n\nIntroducing a Lagrange multiplier $\\lambda$, this problem is equivalent\nto\n\n$$\\max_{r_i} \\left\\{\\sum_{i=1}^N\\,\\varphi_i(r_i)-\\lambda\\,\\left(\\sum_{i=1}^N r_i-1\\right)\\right\\}.$$\n\nAt the optimal point $r_i^\\star$, we must have\n\n$$\\varphi'(r_i^\\star) - \\lambda = 0 \\quad \\forall i \\quad \\Longrightarrow \\quad \\varphi'(r_i^\\star)=\\frac 1 N \\sum_{i=1}^N\\,\\varphi_i'(r_i^\\star)=:\\bar \\varphi'.$$\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The stochastic Lagrangian algorithm\n\nThis leads naturally to the suggested algorithm\n\n\n<font color=\"red\">\nStochastic Lagrangian (SL) algorithm \n\n<br>\n\n$$\\Delta r^{n+1}_i=r^{n+1}_i-r^n_i=\\gamma_n\\,\\left\\{\\varphi'(r_i^n)-\\bar \\varphi'_n\\right\\}$$\n\n</font>\n\n\n-   More quantity is sent to dark pools with higher liquidity $D_i$, as\n    observed in the history of executions.\n\n-   More quantity is sent to the dark pools offering lower-cost\n    execution (<span>*i.e.*</span> greater $\\rho_i$).\n\n-   With various technical assumptions, [Laruelle, Lehalle and Pag\u00e8s]<sup id=\"cite_ref-LLP\" class=\"reference\"><a href=\"#cite_note-LLP\"><span>[</span>4<span>]</span></a></sup> prove the convergence of\n    this algorithm.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Estimation of the $\\rho_i$\n\n-   How would one go about estimating the cost saving (if any)\n    associated with execution in a dark pool (or in a lit venue)?\n\n\n-   The total cost comprises commissions, fees and rebates and most\n    importantly, adverse selection.\n\n    -   Commissions, fees and rebates vary widely between exchanges.\n\n    -   Adverse selection can be proxied by measuring the realized\n        spread: Where is the mid-price (for example) one minute after an\n        execution?\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Discussion of [Laruelle, Lehalle and Pag\u00e8s]<sup id=\"cite_ref-LLP\" class=\"reference\"><a href=\"#cite_note-LLP\"><span>[</span>4<span>]</span></a></sup>\n\n-   The fact that the algorithms of [Laruelle, Lehalle and Pag\u00e8s]<sup id=\"cite_ref-LLP\" class=\"reference\"><a href=\"#cite_note-LLP\"><span>[</span>4<span>]</span></a></sup> explicitly take into account\n    the perceived relative advantages of executions in the various\n    venues is a major strength of their algorithms.\n\n\n-   However, they make no assumption on the distribution of quantity in\n    the dark pool \u2013 we know empirically that this is fat-tailed.\n\n    -   If you submit $r_i\\,V$ and your order is filled in its entirety,\n        there is very likely to be more quantity available.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The Kearns et al. (GKNW) algorithm\n\n-   The idea behind the GNKW algorithm is not dissimilar to the ideas\n    behind the previous algorithms although, as written, it is applied\n    only to dark pools.\n\n\n-   In the <span>*allocation*</span> phase, orders are allocated\n    greedily to the venue with the greatest estimated liquidity.\n\n    -   The greedy algorithm is explained in detail in the GKNW paper\n        and is proved to be optimal in some precise sense.\n\n\n-   In the <span>*re-estimation*</span> phase, the estimated tail\n    quantities of the order-size distributions are updated \n    according to a specified rule.\n\n\n-   Allocation and re-estimation are performed in a continuous loop.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The greedy allocation algorithm\n\n-   Let $P_j(q)$ be the probability of there being $q$ shares at the\n    $j$th venue. Define \n    \n    $$T_j(q)=\\sum_{n\\geq q} P_j(n)$$\n    \n    to be the\n    $j$th tail probability. The empirical estimate of $T_j$ is denoted\n    by $\\hat T_j$.\n\n\n-   If $\\bf v$ is the allocation vector of the total quantity $V$ to the\n    various venues, allocate as follows:\n\n    -   Set ${\\bf v}={\\bf 0}$;\n\n    -   While $\\sum v_i < V$,\n        $i = \\arg \\max_i \\hat T_i(v_i+1)$,\n        $v_i = v_i +1$;\n\n    -   Return ${\\bf v}$.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The Kaplan-Meier estimator\n\n-   If an order is filled in its entirety, we know only that there was\n    at least that much quantity available.\n\n    -   In statistics, this is called a <span>*censored*</span>\n        observation.\n\n-   Let $z(s)=\\Pr(q=s|q \\geq s)$ be the conditional probability that\n    there are exactly $s$ orders given that the quantity available is at\n    least $s$. Then\n\n    \\begin{eqnarray*}\n    T_j(q)=\\Pr(n \\geq q)&=&\\prod_{s=0}^{q-1}\\frac{\\Pr(n \\geq (s+1))}{\\Pr(n \\geq s)}\\\\\n    &=&\\prod_{s=0}^{q-1}\\Pr(n > s | n \\geq s)\\\\\n    &=&\\prod_{s=0}^{q-1}(1-z(s))\\end{eqnarray*}\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The Kaplan-Meier estimator\n\nThe Kaplan-Meier estimator is then\n\n$$\\hat T_j(q)=\\prod_{s=0}^{q-1}(1-\\hat z(s))$$\n\nwhere\n\n$$\\hat z(s)=\\frac{D_s}{N_s}$$\n\nis an empirical estimate of the\nprobability that the available quantity is exactly $s$.\n\n$D_s$ is the number of direct (uncensored) observations and $N_s$ is the\ntotal number of observations (censored and uncensored) that could\npotentially have been $s$.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Modifying Kaplan-Meier\n\n-   [Kearns et al.]<sup id=\"cite_ref-Kearns\" class=\"reference\"><a href=\"#cite_note-Kearns\"><span>[</span>3<span>]</span></a></sup> derive a cut-off point $c_j$ for each venue such that for\n    $s < c_j$, the tail probability estimate $\\hat T_j(s)$ is guaranteed\n    to be close to the true probability $T_j(s)$.\n\n-   In an <span>*Exploitation Lemma*</span> they show that if the\n    allocation to the $j$th venue is less than $c_j$, there is\n    sufficient data to estimate the tail probability and the allocation\n    is provably optimal.\n\n    -   In this case, the Kaplan-Meier estimate is used as $\\hat T_j(s)$\n        in the allocation algorithm, without modification.\n\n-   If $s > c_j$, the tail probability is optimistically estimated as\n    $\\hat T_j(s)=\\hat T_j(c_j)$.\n\n    -   By making this \u201coptimistic\u201d modification to the K-M estimate,\n        the authors ensure that no venue remains unexplored simply\n        because the algorithm has only a few observations of small\n        quantity from that venue.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### The main result\n\n#### <font color=\"red\"> Theorem\nFor any $\\epsilon > 0$ and $\\delta >0$, with probability $1-\\delta$,\nafter running for a time polynomial in $N$, $V$, $1/\\epsilon$ and\n$\\log 1/\\delta$, the algorithm makes an $\\epsilon$-optimal allocation on\neach subsequent time step with probability at least $1-\\epsilon$.\n</font>\n\n-   Recall that $N$ is the number of venues and $V$ is the total\n    quantity to be traded.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Parametric quantity distributions\n\n-   In practice, the Kaplan-Meier estimate of tail probability does very\n    well in-sample but not surprisingly not very well out-of-sample due\n    to serious over-fitting.\n\n\n-   By splitting a large sample of dark-pool trades into a training set\n    and a test set, [Kearns et al.]<sup id=\"cite_ref-Kearns\" class=\"reference\"><a href=\"#cite_note-Kearns\"><span>[</span>3<span>]</span></a></sup> were able to show that the parametric form\n    ZB+power-law works best.\n\n    -   That is, one estimates the probability of zero quantity\n        separately (most of the time there is zero quantity), and fits a\n        power-law of the form $1/s^\\beta$ to the rest of the data.\n\n    -   $\\beta$ is found to lie mostly between $0.25$ and $1.3$. Compare\n        with our previous stylized fact that quantity is distributed\n        according to a 3/2 law.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### A simulation study\n\n-   As is usual with these problems, an algorithm can only be tested by\n    experiment or simulation.\n\n    -   The data comes from particular choices of algorithm and we can\u2019t\n        predict what would have been if the algorithm had chosen to act\n        differently.\n\n-   It being impossible to experiment, the authors chose simulation.\n\n-   Four algorithms are compared:\n\n    -   Ideal allocation from knowing the true distributions used for\n        the simulation.\n\n    -   Equal allocation across venues\n\n    -   The GKNW learning algorithm with ZB+Power Law parameterization\n\n    -   A <span>*bandit*</span> algorithm that begins with equal\n        weights. If there is any execution at a particular venue, that\n        venues weight is increased by a factor $\\alpha=1.05$.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Simulation results\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/Simulation.png\" align = \"center\" width=500></h2>\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Why do new venues attract any order flow?\n\n-   Once a venue has volume, it\u2019s clear to see that it is optimal to\n    route some part of your order flow to that venue.\n\n-   Why does the new venue attract any flow to start with?\n\n-   Part of the answer might lie in the use of algorithms like GNKW.\n\n    -   A machine-learning algorithm will always allocate a minimum\n        amount of flow to a given venue; otherwise that venue will\n        remain unexplored.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Understanding order routing decisions\n\n-   [Maglaras, Moallemi and Zheng]<sup id=\"cite_ref-Maglaras\" class=\"reference\"><a href=\"#cite_note-Maglaras\"><span>[</span>5<span>]</span></a></sup> explore order routing decisions, treating multiple order\n    books as a multiple queuing system as follows:\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Limit order routing\n\n-   There are two types of order flow to a given exchange $i$:\n\n    -   Dedicated order flow $\\lambda_i$\n\n    -   Optimized order flow $\\Lambda$, some of which arrives at\n        exchange $i$\n\n-   A limit order submitter characterized by $\\gamma$ routes his order\n    so as to maximize a utility of the form\n    \n    $$\\gamma\\,\\tilde r _i-\\text{ED}_i$$\n    \n    where the expected delay\n    $\\text{ED}_i=Q_i/\\mu_i$ where the queue length is $Q_i$ and the\n    market order arrival rate is $\\mu_i$. $\\tilde r_i$ is the net cost\n    of routing to $i$ including rebates and adverse selection.\n\n    -   This tradeoff between time and cost is reminiscent of the Ro\u015fu\n        model setup described in Lecture 2.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Complicated BATS Fees\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/BATSfees.png\" align = \"center\" width=550></h2>\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Approximate exchange fee schedules as of Apr-2012\n\nIn dollars per share:\n\n|Exchange   |  Make Fee  |  Take fee |\n|-----------|-----------:|----------:|\n|NASDAQ     |     -0.0029|    +0.0027|\n|NYSE       |     -0.0017|    +0.0022|\n|NYSE Arca  |     -0.0030|    +0.0030|\n|BATS       |     -0.0029|    +0.0029|\n|EDGX       |     -0.0023|    +0.0029|\n|NASDAQ BX  |     +0.0015|    -0.0014|\n|BATS Y     |      0.0000|    +0.0003|\n|EDGA       |     -0.0003|    +0.0007|\n|NASDAQ PSX |     -0.0018|    +0.0019|"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Market order routing\n\n-   [Maglaras, Moallemi and Zheng]<sup id=\"cite_ref-Maglaras\" class=\"reference\"><a href=\"#cite_note-Maglaras\"><span>[</span>5<span>]</span></a></sup> present a model in which market orders are routed to\n    exchanges based on various factors, including of course the take fee\n    which is assumed to be equal to the rebate.\n\n-   They prove the existence of an equilibrium.\n\n-   In equilibrium, relative queue lengths $Q_i$ are ordered according\n    to rebates.\n\n-   We see from [Figure 64](#figure64) (from [Maglaras, Moallemi and Zheng]<sup id=\"cite_ref-Maglaras\" class=\"reference\"><a href=\"#cite_note-Maglaras\"><span>[</span>5<span>]</span></a></sup>) that the resulting\n    $Q_i$ are indeed ordered according to rebates.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Empirical confirmation\n<h2><img src=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/04/MaglarasQueues.png\" align = \"center\" width=600></h2>\n<a name=\"figure64\"></a>\n\nFigure 4: Queue times are functions of make/take fee structure (from\n[Maglaras, Moallemi and Zheng]<sup id=\"cite_ref-Maglaras\" class=\"reference\"><a href=\"#cite_note-Maglaras\"><span>[</span>5<span>]</span></a></sup>"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Cont and Kukanov: optimal limit order placement\n\n-   Assume a buy order\n\n-   Venues $k=1,...,K$ are characterized by\n\n    -   Bid queue lengths $Q_k$\n\n    -   Make rebates $r_k$, take fees $f_k$, half-spread $h = s/2$.\n\n-   Simplify by assuming that any market order is sent to the venue with\n    the smallest take fee $f$.\n\n-   Order placement strategy is $X= \\left(M,L_1,...,L_K\\right)$ where\n    the components represent volumes of the single market order and the\n    $k$th limit orders respectively.\n\n-   The tradeoff is between cost and execution probability.\n\n    -   On a given exchange, the lower the price of the limit order, the\n        lower the probability of execution\n\n    -   On multiple exchanges, the higher the rebate, the longer the\n        queue length, the lower the probability of execution.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Objective function\n\n-   Denote duration of child order by $T$.\n\n-   $\\xi_k$ is the (random) outflow of limit orders (from market order\n    fills and cancelations) at venue $k$ in the interval $[0,T]$.\n\n-   Executed quantity is given by\n\n    $$\\mathcal{A} (X,\\xi) = M + \\sum_k \\left\\{(\\xi_k-Q_k)^+ - (\\xi_k-Q_k-L_k)^+  \\right\\}$$\n    \n\n-   Cost relative to mid-quote is given by\n\n    $$\\mathcal{C} (X,\\xi) = (h+f)\\,M -  \\sum_k (h + r_k)\\,\\left\\{(\\xi_k-Q_k)^+ - (\\xi_k-Q_k-L_k)^+  \\right\\}$$\n    \n\n-   Penalize under- or over-fills relative to target quantity $\\tilde X$\n    with penalty\n    \n    $$\\mathcal{P} (X,\\xi) = \\lambda_u(\\tilde X - \\mathcal{A} )^+ +  \\lambda_o\\,(\\mathcal{A} - \\tilde X)^+.$$\n\n    -   $\\lambda_u$ and $\\lambda_o$ price adverse selection.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Optimal order placement strategy\n\n-   The optimal order placement strategy $X^*$ is given by\n\n    $$X^* = \\arg \\min_X \\mathbb{E} \\left[{\\mathcal{A} (X,\\xi) + \\mathcal{P} (X,\\xi)}\\right]$$\n    \n\n-   Assuming it is suboptimal to exceed the target $\\tilde X$ and that\n    it is better to execute with limit orders that market orders, Cont\n    and Kukanov show that there is an optimal strategy.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Solution for single venue\n\n-   If $\\lambda_u$ is in a suitable range,\n\n    $$L^* =F^{-1} \\left(\\frac{2 h + f + r}{\\lambda_u + h + r}\\right)-Q , \\quad\\quad M^* = \\tilde X - L^*.$$\n    \n    where $F(\\cdot)$ denotes the distribution of $\\xi$ (which is\n    increasing in $\\xi$).\n\n-   Comparative statics. $L^*$ is:\n\n    -   decreasing in $Q$,\n\n    -   increasing in $h$,\n\n    -   increasing in $f$,\n\n    -   decreasing in $\\lambda_u$,\n\n    -   increasing in $r$.\n\n-   As the target size $\\tilde X$ increases, $L^*$ is fixed and $M^*$\n    increases.\n\n-   $F(\\cdot)$ may be estimated in real time using recent outflow data\n    (and potentially other signals).\n\n    -   $F(\\cdot)$ need not be parametric.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Solution for multiple venues\n\n-   When the allocation is optimal,\n\n    \\begin{eqnarray*}\n    \\mathbb{P}\\left(\\mathcal{A} (X^*,\\xi)<\\tilde X\\right)&=& \\frac{h+f+\\lambda_o}{\\lambda_u+\\lambda_o}\\\\\n    \\mathbb{P}\\left(\\left.\\mathcal{A} (X^*,\\xi)<\\tilde X \\right| \\xi_j > Q_j + L^*_j\\right)&=& \\frac{\\lambda_o-(h+r_j)}{\\lambda_u+\\lambda_o}\\end{eqnarray*}\n\n    -   Note that the bigger the rebate $r_j$ on a given exchange, the\n        lower the conditional shortfall probability.\n\n    -   This can be used to define $\\lambda_u$ and $\\lambda_o$ in terms\n        of maximal under-fill probabilities.\n\n-   One interesting insight from the solution is that execution cost is\n    lower with multiple venues relative to a single venue if the\n    outflows $\\xi_k$ are sufficiently uncorrelated.\n\n    -   This amounts to a condition for optimality of order-flow\n        fragmentation.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### A remark\n\n<font color=\"red\">\n#### Remark\n$$^{\\text{ }}$$\n\nWhereas [Maglaras, Moallemi and Zheng]<sup id=\"cite_ref-Maglaras\" class=\"reference\"><a href=\"#cite_note-Maglaras\"><span>[</span>5<span>]</span></a></sup> shows that in equilibrium, the $Q_k$ should be ordered\naccording to the $r_k$, [Cont and Kukanov]<sup id=\"cite_ref-ContKukanov\" class=\"reference\"><a href=\"#cite_note-ContKukanov\"><span>[</span>2<span>]</span></a></sup> show how to minimize execution cost\nby taking advantage of deviations from the equilibrium configuration.\nOne could think of using realized spread as a proxy for $r_k$ which\ntakes into account execution quality.\n\nFragmented markets are better for you if order flow is not perfectly\ncorrelated between exchanges and you have a good smart order router.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Summary\n\n-   The cost of latency can be estimated using a simple formula that\n    uses only volatility and spread.\n\n    -   The benefit of extra technology investment can be estimated on\n        the back of an envelope.\n\n-   We have presented various smart order routing algorithms, some of\n    which are provably optimal in some sense.\n\n    -   A better algorithm would incorporate the best features of the\n        best of these algorithms (SL and AH?).\n\n-   The model of [Maglaras, Moallemi and Zheng]<sup id=\"cite_ref-Maglaras\" class=\"reference\"><a href=\"#cite_note-Maglaras\"><span>[</span>5<span>]</span></a></sup> shows how optimal order routing establishes\n    relationships between the available liquidity and order flows on the\n    various exchanges.\n\n-   [Cont and Kukanov]<sup id=\"cite_ref-ContKukanov\" class=\"reference\"><a href=\"#cite_note-ContKukanov\"><span>[</span>2<span>]</span></a></sup> show how to optimally distribute limit orders and\n    market orders between venues based on estimation of execution\n    probabilities, rebates and fees.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### A philosophical question\n\n<font color=\"red\">\n####<span>Question</span>\nWhy should it be so complicated to trade stock?\n\n<font color=\"black\">\nOne answer goes something like this:\n\n-   Changes in market structure together with technological innovation\n    have massively reduced trading costs.\n\n-   Nevertheless, some market participants achieve significantly lower\n    costs.\n\n    -   This requires either substantial investment in technology and\n        trading expertise or\n\n    -   careful selection of broker algorithms.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Potential cost savings from optimal scheduling\n\nWith reasonable assumptions, assuming the square-root model, savings\nrelative to a simple VWAP are roughly of the following order:\n\n-   Around 15% for the Alfonsi-Fruth-Schied bucket-like strategy\n\n-   Around 25% for a suitable bursty strategy (intermittent interval\n    VWAPs) with a capped participation rate.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Potential cost savings from microtrader improvements\n\n-   Were we just to blindly send market orders, we would estimate that\n    the cost of each child order would be around a half-spread.\n\n-   Practical experience shows that it is not possible to reduce this\n    cost much below one third of a spread.\n\n-   We conclude that we could potentially save up to one sixth of the\n    spread.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Potential cost savings from smart order routing\n\n-   A na\u00efve estimate would be to use the square-root market impact\n    formula, changing the denominator $V$ to reflect the potential\n    increase in liquidity from routing to extra venues.\n\n    -   If the potential liquidity accessed is doubled, costs should be\n        decreased by $1-1/\\sqrt{2} \\approx 30\\%$ according to this\n        simple computation!\n\n    -   This could be one explanation for the multiplicity of trading\n        venues in the US.\n\n\n-   We expect actual savings to be much less than this because the\n    different venues are all connected and information leaks from one\n    venue to the other.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### Final conclusion\n\n-   Recent empirical and theoretical work on market microstructure has\n    led to a much improved understanding of how to trade optimally.\n\n\n-   Potential savings from careful order execution relative to VWAP\n    using a simple first-generation algorithm are substantial.\n\n    -   Relative to a na\u00efve strategy, cost savings of $25\\%$ for\n        reasonably sized orders are not unreasonable.\n\n"
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "slideshow": {
       "slide_type": "slide"
      }
     },
     "source": "### References\n\n<br />\n\n<div class=\"reflist\" style=\"list-style-type: decimal;\">\n\n<ol>\n\n  <li id=\"cite_note-AlmgrenHarts\"><span class=\"mw-cite-backlink\"><b><a href=\"#cite_ref-AlmgrenHarts\">^</a></b></span>Robert Almgren and Bill Harts, A dynamic algorithm for smart order\nrouting, <span>*White paper StreamBase*</span> (2008).\n  </li>\n  \n    <li id=\"cite_note-ContKukanov\"><span class=\"mw-cite-backlink\"><b><a href=\"#cite_ref-ContKukanov\">^</a></b></span>Rama Cont and Arseniy Kukanov, Optimal order placement in limit order\nmarkets, available at <http://ssrn.com/abstract=2155218> (2013).\n  </li>\n  \n    <li id=\"cite_note-Kearns\"><span class=\"mw-cite-backlink\"><b><a href=\"#cite_ref-Kearns\">^</a></b></span>Kuzman Ganchev, Michael Kearns, Yuriy Nevmyvaka and Jennifer Wortman\nVaughan, Censored exploration and the dark pool problem,\n<span>*Communications of the ACM*</span> <span>**53**</span>(5) (2010).\n  </li>\n  \n    <li id=\"cite_note-LLP\"><span class=\"mw-cite-backlink\"><b><a href=\"#cite_ref-LLP\">^</a></b></span>Sophie Laruelle, Charles-Albert Lehalle, and Gilles Pag\u00e8s, Optimal split\nof orders across liquidity pools: a stochastic algorithm approach,\n<span>*SIAM Journal on Financial Mathematics*</span>\n<span>**2**</span>(1) 1042\u20131076 (2011).\n  </li>\n  \n    <li id=\"cite_note-Maglaras\"><span class=\"mw-cite-backlink\"><b><a href=\"#cite_ref-Maglaras\">^</a></b></span>Costis Maglaras, Ciamac C Moallemi, and Hua Zheng, Optimal order routing\nin a fragmented market,\n<http://moallemi.com/ciamac/papers/multilob-2012.pdf>\n  </li>\n  \n    <li id=\"cite_note-Moallemi\"><span class=\"mw-cite-backlink\"><b><a href=\"#cite_ref-Moallemi\">^</a></b></span>Ciamac Moallemi and Mehmet Sa\u011flam, The cost of latency,\n<span>*Operations Research*</span> <span>**61**</span>(5) 1070\u20131086\n(2013).\n  </li>\n\n  \n</ol>"
    }
   ],
   "metadata": {}
  }
 ]
}